using SharePoint.Security.ConfigAnalyzer.Engine.Base;
using SharePoint.Security.ConfigAnalyzer.Engine.Common;
using Microsoft.SharePoint.Administration;

namespace SharePoint.Security.ConfigAnalyzer.Engine.Rules.Diagnostic
{
    public class MonitoringRestrictTraceLog : BaseRule
    {
        public MonitoringRestrictTraceLog()
        {
            RuleInfo = new RuleInfo
                           {
                               Title = "Trace log Disk Usage",
                               Description = "Restrict Trace Log disk space usage setting under Diagnostic Logging should be turned on Central Admin > Monitoring> Diagnostic Logging > Metrics.aspx",
                               ExpectedValue = "True"
                           };
        }

        #region Overrides of BaseRule

        public override void Validate()
        {
            var diagSvc = ObjectHelper.Diagnostics;

            if (diagSvc.LogMaxDiskSpaceUsageEnabled)
            {
                Status = Status.Pass;
            }
            else
            {
                Status = Status.Fail;
            }

            CurrentValue = diagSvc.LogMaxDiskSpaceUsageEnabled.ToString();
        }

        #endregion
    }
}